import request from '../utils/request';
import { parse } from 'querystring';

export const getPageQuery = () => parse(window.location.href.split('?')[1]);

export async function accountLogin(params) {
  const { username, password } = params;
  const data = { username, password };
  console.log(data);

  let rep = {};
  if (username === 'admin' && password === 'wxgj888') {
    rep.code = 200;
    rep.data = {};
    rep.data.token = 'tttt';
    rep.data.auth = 'ROLE_ADMIN';
  } else {
    rep.code = 401;
  }

  return rep;
  // return request('http://localhost:8080/auth/login', {
  //   method: 'POST',
  //   data,
  // }).then(function(response) {
  //   console.log(response);
  //   return response;
  // }).catch(function(error) {
  //   console.log(error);
  // });
}
